import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
//引入svg
import  { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import { viteMockServe } from 'vite-plugin-mock'

export default defineConfig(({ command }) => {
  return{
    //scss全局变量配置
    css: {
      preprocessorOptions : {
        scss :{
          additionalData: '@use "@/style/variable.scss" as *;'
        }
      }
    },
    plugins: [
      vue(),
      VueSetupExtend(),
      createSvgIconsPlugin({
        iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
        symbolId:'icon-[dir]-[name]'
      }),
      viteMockServe({
        mockPath: 'mock', // mock文件夹路径
        enable: command === 'serve' // 只有开发环境才开启mock
      })
    ],
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    }
  }
});
